/**
 * flat
 */
const nums = [1, 2, 3, 4, [5, 6, 7], [[8, 9], [10, 11]]]
const newN = nums.flat() //默认降1维
console.log(newN)

//可以设置降维深度
const newN2 = nums.flat(2)
console.log(newN2)

/**
 * flatMap
 *  - 先进性map操作，再做flat操作
 *  - flatMap中的flat相当于深度为1
 */
const nums2 = [1, 2, 3, 4]
const newNums2 = nums2.flatMap(item => {
  return item * 2
})
console.log(newNums2)

const msg = ['hello world', 'hello lj', 'my name is pbb']
const words = msg.flatMap(item => item.split(' ')
)
console.log(words)
const words1 = msg.map(item => item.split(' ')
)
console.log(words1)
